package com.aaa.system.dao;

import com.aaa.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @program: aaa-his-parent
 * @description:
 * @author: 闫克起
 * @create: 2023-12-07 11:56
 **/
public interface MenuDao extends BaseMapper<Menu> {

    @Select("select m.* from sys_menu m join sys_role_menu rm on m.menu_id=rm.menu_id join sys_role_user ru on rm.role_id=ru.role_id where ru.user_id=#{userId} and m.status=0")
    public List<Menu> selectMenusByUserId(Long userId);

    @Select("select distinct m.* from sys_menu m join sys_role_menu rm on m.menu_id=rm.menu_id join sys_role_user ru on rm.role_id=ru.role_id" +
            " join sys_user u on u.user_id=ru.user_id where u.phone=#{phone} and m.status=0")
    public List<Menu> selectMenusByPhone(String phone);
}
